package com.tudouji.project.flow.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.flow.domain.Flowconditions;
import com.tudouji.project.flow.service.IFlowconditionsService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 流程条件Controller
 * 
 * @author tudouji
 * @date 2021-05-06
 */
@RestController
@RequestMapping("/flow/flowconditions")
public class FlowconditionsController extends BaseController
{
    @Autowired
    private IFlowconditionsService flowconditionsService;

    /**
     * 查询流程条件列表
     */
//    @PreAuthorize("@ss.hasPermi('flow:flowconditions:list')")
//    @GetMapping("/list")
//    public TableDataInfo list(Flowconditions flowconditions)
//    {
//        startPage();
//        List<Flowconditions> list = flowconditionsService.selectFlowconditionsList(flowconditions);
//        return getDataTable(list);
//    }

    @PreAuthorize("@ss.hasPermi('flow:flowconditions:list')")
    @GetMapping("/list")
    public TableDataInfo list(Flowconditions flowconditions)
    {
        startPage();
        List<Flowconditions> list = flowconditionsService.selectFlowConditionsList(flowconditions);
        return getDataTable(list);
    }


    /**
     * 导出流程条件列表
     */
    @PreAuthorize("@ss.hasPermi('flow:flowconditions:export')")
    @Log(title = "流程条件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Flowconditions flowconditions)
    {
        List<Flowconditions> list = flowconditionsService.selectFlowconditionsList(flowconditions);
        ExcelUtil<Flowconditions> util = new ExcelUtil<Flowconditions>(Flowconditions.class);
        return util.exportExcel(list, "flowconditions");
    }

    /**
     * 获取流程条件详细信息
     */
//    @PreAuthorize("@ss.hasPermi('flow:flowconditions:query')")
//    @GetMapping(value = "/{guid}")
//    public AjaxResult getInfo(@PathVariable("guid") String guid)
//    {
//        return AjaxResult.success(flowconditionsService.selectFlowconditionsById(guid));
//    }

    @PreAuthorize("@ss.hasPermi('flow:flowconditions:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(flowconditionsService.selectFlowConditionsById(id));
    }

    /**
     * 新增流程条件
     */
//    @PreAuthorize("@ss.hasPermi('flow:flowconditions:add')")
//    @Log(title = "流程条件", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody Flowconditions flowconditions)
//    {
//        return toAjax(flowconditionsService.insertFlowconditions(flowconditions));
//    }

    @PreAuthorize("@ss.hasPermi('flow:flowconditions:add')")
    @Log(title = "流程条件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Flowconditions flowconditions)
    {
        return toAjax(flowconditionsService.insertFlowConditions(flowconditions));
    }

    /**
     * 修改流程条件
     */
//    @PreAuthorize("@ss.hasPermi('flow:flowconditions:edit')")
//    @Log(title = "流程条件", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody Flowconditions flowconditions)
//    {
//        return toAjax(flowconditionsService.updateFlowconditions(flowconditions));
//    }

    @PreAuthorize("@ss.hasPermi('flow:flowconditions:edit')")
    @Log(title = "流程条件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Flowconditions flowconditions)
    {
        return toAjax(flowconditionsService.updateFlowConditions(flowconditions));
    }

    /**
     * 删除流程条件
     */
//    @PreAuthorize("@ss.hasPermi('flow:flowconditions:remove')")
//    @Log(title = "流程条件", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{guids}")
//    public AjaxResult remove(@PathVariable String[] guids)
//    {
//        return toAjax(flowconditionsService.deleteFlowconditionsByIds(guids));
//    }

    @PreAuthorize("@ss.hasPermi('flow:flowconditions:remove')")
    @Log(title = "流程条件", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable Long id)
    {
        return toAjax(flowconditionsService.deleteFlowConditionsById(id));
    }


}
